package com.youku.controls
{
   import com.youku.plugins.endcardV4New.EndCardFacade;
   import com.youku.events.PluginEvent;
   import com.youku.events.PlayerControlEvent;
   import com.youku.utils.OpenWindow;
   import flash.net.URLRequest;
   
   public class EndCardV4NewController extends BasePluginController
   {
      
      public function EndCardV4NewController() {
         super();
         this.init();
      }
      
      private var _endCardFacade:EndCardFacade;
      
      override protected function init() : void {
         this._endCardFacade = EndCardFacade.getInstance();
         this._endCardFacade.init(viewManager.pluginLayer,playerProxy);
         playerProxy.addEventListener(PluginEvent.ENDCARD_SHARE,this.onEndcardEvent);
         playerProxy.addEventListener(PluginEvent.ENDCARD_CHANGE_FULLSCREEN,this.onEndcardEvent);
         playerProxy.addEventListener(PluginEvent.ENDCARD_REPLAY,this.onEndcardEvent);
         playerProxy.addEventListener(PluginEvent.ENDCARD_PLAY_VIDEO,this.onEndcardEvent);
         playerProxy.addEventListener(PluginEvent.ENDCARD_SEARCH,this.onEndcardEvent);
         playerProxy.addEventListener(PluginEvent.ENDCARD_FAVORITE_CLICK,this.onEndcardEvent);
      }
      
      private function onEndcardEvent(param1:PluginEvent) : void {
         var _loc2_:String = null;
         switch(param1.type)
         {
            case PluginEvent.ENDCARD_REPLAY:
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.HIDE_END_CARD));
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.ENDCARD_REPLAY));
               conductor.replay(0);
               break;
            case PluginEvent.ENDCARD_PLAY_VIDEO:
               break;
            case PluginEvent.ENDCARD_SEARCH:
               _loc2_ = param1.data as String;
               OpenWindow.open(new URLRequest(_loc2_),"_blank");
               break;
            case PluginEvent.ENDCARD_SHARE:
               facadeManager.showShareBox("share");
               break;
            case PluginEvent.ENDCARD_CHANGE_FULLSCREEN:
               changeFullScreenMode();
               break;
            case PluginEvent.ENDCARD_FAVORITE_CLICK:
               externalInterfaceProxy.playerVideoFav(playerProxy.playerData.videoIdEncode);
               break;
         }
      }
   }
}
